/* ----------------------------- Marlin Toolkit----------------------------*
Authors : Daniel Randle, Alex Bourne
Date Created : Feb 25 2013

File:
	mainwindow.h

Description:
	This file contains the necessary declarations of the main window class which is
	the parent to all GUI elements in the toolkit. Style sheets set here will
	propagate throughout the program.
*---------------------------------------------------------------------------*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H


// Includes
#include <global.h>
#include <qmainwindow.h>

// Class declarations
class QDockWidget;
class QGLWidget;
class QMenu;
class QAction;
class QToolBar;
class QResizeEvent;
class Toolkit;
class NSEngine;
#ifdef DEBUG
class Debug;
#endif

/* ---------------------------------Class MainWindow-----------------------------*

Inherits : QMainWindow

Namespace : ToolkitGui

Description:
	This class is the manager for the GUI portion of the tookit. The other objects
	that the GUI represents are also used in the engine - however the GUI code is
	used in the toolkit only. It is responsible for keeping track of all dialogs,
	menus, toolbars, buttons, and any other GUI elements in a way that makes
	it possible for the engine classes to interface.

*-----------------------------------------------------------------------------*/
namespace ToolkitGui
{
	// Windows
	class MapWindow;
	class ObjectWindow;
	class MapSelectionWindow;
	class MarkerWindow;
	class ShaderWindow;
	class UndoWindow;
	class ShaderBuildWindow;

	#ifdef DEBUG
	class DebugWindow;
	#endif

	class MainWindow : public QMainWindow
	{
		Q_OBJECT
	public:
		MainWindow(Toolkit * tk);  // No parents of main window
		~MainWindow();

		void setEngine(NSEngine * eng);

		// Getting views

		MapWindow * getMapWindow();
		ObjectWindow * getObjectWindow();
		MapSelectionWindow * getMapSelectionWindow();
		MarkerWindow * getMarkerWindow();
		ShaderWindow * getShaderWindow();
		UndoWindow * getUndoWindow();
		ShaderBuildWindow * getShaderBuildWindow();

		void myUpdate();

		#ifdef DEBUG
		void setDebug(Debug * debug);
		#endif

	protected:
		virtual void resizeEvent ( QResizeEvent * event );

	private slots:
		void onSavePlugin();
		void onLoadPlugin();
		void onToggleOccupiedTiles(bool);

	private:
		// Helper functions (set up)
		void _initWindows();
		void _initDialogs();
		void _initObjects();  // not dialogs or windows
		void _setupActions();
		void _setupMenus();
		void _setupToolBars();
		void _setupDockWindows();
		void _setupUi();
		void _setupConnections();

		// Windows
		MapWindow * mapWindow;
		ObjectWindow * objectWindow;
		MapSelectionWindow * mapSelectionWindow;
		MarkerWindow * markerWindow;
		ShaderWindow * shaderWindow;
		UndoWindow * undoWindow;
		ShaderBuildWindow * shaderBuildWindow;

		// Toolkit
		Toolkit * toolkit;

		// Engine
		NSEngine * engine;

		#ifdef DEBUG
		Debug * d;
		DebugWindow * debugWindow;
		#endif


		// Actions
		QAction * savePluginA;
		QAction * loadPluginA;
		QAction * toggleShowOccupiedTiles;

		// Menus
		QMenu * fileMenu;
		QMenu * editMenu;
		QMenu * viewMenu;

		// Toolbars
		QToolBar * mainToolBar;

		// Dock Windows
		QDockWidget * mapDock;
		QDockWidget * mapSelectionDock;
		QDockWidget * objectDock;
		QDockWidget * markerDock;
		QDockWidget * shaderDock;
		QDockWidget * undoDock;
		QDockWidget * shaderBuildDock;
		#ifdef DEBUG
		QDockWidget * debugDock;
		#endif
	};
}

#endif // TOOLKIT_H
